home *** CD-ROM | disk | FTP | other *** search
/ TeX 1995 July / TeX CD-ROM July 1995 (Disc 1)(Walnut Creek)(1995).ISO / macros / latex209 / contrib / zero / zero.sty < prev   
Text File  |  1993-11-07  |  5KB  |  113 lines

  1. % LaTeX documentstyle option to start numbering at zero (where appropriate)
  2. %
  3. % Tom Verhoeff
  4. % Department of Mathematics and Computing Science
  5. % Eindhoven University of Technology
  6. % The Netherlands
  7. % E-mail: <wstomv@win.tue.nl>
  8. %
  9. \def\filedate{19 June 1991}
  10. %
  11. \typeout{Documentstyle option `zero': start numbering at zero.  <\filedate>}
  12. %
  13. % USAGE
  14. %
  15. % Include `zero' in the list of documentstyle options.
  16. % This initializes all existing counters such that numbering, where appropriate,
  17. % starts at zero (instead of one).  Numbering still starts at one for
  18. %    (i)  footnotes on the title page,
  19. %   (ii)  parts,
  20. %  (iii)  footnotes in minipages,
  21. %   (iv)  enumerated lists nested two levels or deeper,
  22. % since these use a non-arabic numbering format.
  23. % Furthermore, newly defined counters will be initialized such that numbering
  24. % starts at zero.  When you change the numbering format of a counter to
  25. % non-arabic, it is advisable to change the initial value to one as well.
  26. %
  27. % To change the initial value of counter <cntr> use
  28. %    \initcounter{<cntr>}{<value>}
  29. % This also resets the counter to its (new) initial value.
  30. % For example, page numbering can be start at one by \initcounter{page}{1}.
  31. % N.B.  All counters, except page for page numbering, have a value ONE LESS
  32. % than the next number produced.  So to start numbering at one for enumerated
  33. % lists at the outermost level use \initcounter{enumi}{0}.
  34. %
  35. % To reset counter <cntr> to its (current) initial value use
  36. %    \resetcounter{<cntr>}
  37. %
  38. % IMPLEMENTATION DETAILS
  39. %
  40. % New macros: \initcounter, \resetcounter
  41. %
  42. % The macro \initcounter{<cntr>}{<value>} records <value> as the initial
  43. % value of the numbering counter <cntr>, and resets <cntr>.
  44. % The initial value of <cntr> is stored in the control sequence \ci@<cntr>.
  45. % The macro \resetcounter{<cntr>} resets <cntr> to its initial value \ci@<cntr>.
  46. %
  47. % The macros \@stpelt, \@definecounter, \usercounter, \pagenumbering,
  48. % \maketitle, and \@iminipage have been redefined to use \initcounter or
  49. % \resetcounter.
  50. %
  51. % The macro \appendix needs no revision, even though it sets the counters
  52. % (chapter,) section and subsection to 0.  The section counter (cq. chapter
  53. % counter for report and book) is printed in Alpha and consequently should
  54. % indeed be reset to 0.  The subsection counter (and section counter for
  55. % report and book) is reset appropriately whenever the section (cq. chapter)
  56. % counter is stepped.  Only if sectioning is done incorrectly,
  57. % e.g. by starting the appendix with a subsection, then numbering may also
  58. % be done incorrectly.
  59. %
  60. \def\resetcounter#1{\setcounter{#1}{\csname ci@#1\endcsname}}
  61. \def\initcounter#1#2{% set initial value for counter
  62.   \global\expandafter\let\csname ci@#1\endcsname#2\relax
  63.   \resetcounter{#1}}
  64. \let\@stpelt\resetcounter
  65. \def\@definecounter#1{%
  66.   \expandafter\newcount\csname c@#1\endcsname%
  67.   \initcounter{#1}{\m@ne}%
  68.   \expandafter\gdef\csname cl@#1\endcsname{}%
  69.   \@addtoreset{#1}{@ckpt}%
  70.   \expandafter\gdef\csname p@#1\endcsname{}%
  71.   \expandafter\gdef\csname the#1\endcsname{\arabic{#1}}}
  72. \def\usecounter#1{\@nmbrlisttrue\def\@listctr{#1}\resetcounter{#1}}
  73. \def\pagenumbering#1{\resetcounter{page}%
  74.   \gdef\thepage{\csname @#1\endcsname\c@page}}
  75. \let\@ldmaketitle=\maketitle% save old \maketitle macro
  76. \def\maketitle{%
  77.   \setcounter{footnote}{0}% because \thanks uses symbolic footnote marks
  78.   \@ldmaketitle%
  79.   \resetcounter{footnote}}
  80. \def\@iminipage[#1]#2{\leavevmode \@pboxswfalse
  81.    \if #1b\vbox 
  82.      \else \if #1t\vtop 
  83.               \else \ifmmode \vcenter 
  84.                         \else \@pboxswtrue $\vcenter
  85.                      \fi
  86.            \fi
  87.     \fi\bgroup
  88.     \hsize #2\textwidth\hsize \columnwidth\hsize
  89.     \@parboxrestore 
  90.     \def\@mpfn{mpfootnote}\def\thempfn{\thempfootnote}\resetcounter{mpfootnote}
  91.     \let\@footnotetext\@mpfootnotetext
  92.     \let\@listdepth\@mplistdepth \@mplistdepth\z@
  93.     \@minipagerestore\global\@minipagetrue %% \global added 24 May 89
  94.     \everypar{\global\@minipagefalse\everypar{}}}
  95.  
  96. %
  97. % Reinitialize already existing counters to -1 so as to start counting at 0,
  98. % EXCEPT FOR:
  99. %  * page numbers, because the page count has no lag.  Reinitialized at 0.
  100. %  * part numbers, minipage footnote numbers, and enumerated environments
  101. %    nested 2 or deeper, because they do not use the arabic format.
  102. %    Reinitialized at 0.
  103. %
  104. {\def\@elt#1{\initcounter{#1}{\m@ne}}\cl@@ckpt}
  105. \initcounter{page}{\z@}
  106. \initcounter{part}{\z@}
  107. \initcounter{mpfootnote}{\z@}
  108. \initcounter{enumii}{\z@}
  109. \initcounter{enumiii}{\z@}
  110. \initcounter{enumiv}{\z@}
  111. %
  112. % End of file zero.sty
  113.